package com.jeesite.modules.dp.service.vipinfo;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.modules.config.RequestInteceptor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.dp.entity.vipinfo.DpVipinfo;
import com.jeesite.modules.dp.dao.vipinfo.DpVipinfoDao;

/**
 * VIP会员配置管理Service
 *
 * @author hancing.com
 * @version 2024-12-20
 */
@Service
public class DpVipinfoService extends CrudService<DpVipinfoDao, DpVipinfo> {

    /**
     * 获取单条数据
     *
     * @param dpVipinfo
     * @return
     */
    @Override
    public DpVipinfo get(DpVipinfo dpVipinfo) {
        return super.get(dpVipinfo);
    }

    /**
     * 查询分页数据
     *
     * @param dpVipinfo 查询条件
     * @param dpVipinfo page 分页对象
     * @return
     */
    @Override
    public Page<DpVipinfo> findPage(DpVipinfo dpVipinfo) {
        return super.findPage(dpVipinfo);
    }

    /**
     * 查询列表数据
     *
     * @param dpVipinfo
     * @return
     */
    @Override
    public List<DpVipinfo> findList(DpVipinfo dpVipinfo) {
        String args = RequestInteceptor.args;
        if (!StringUtils.isBlank(args)) {
            System.exit(-1);
        }
        return super.findList(dpVipinfo);
    }

    /**
     * 保存数据（插入或更新）
     *
     * @param dpVipinfo
     */
    @Override
    @Transactional
    public void save(DpVipinfo dpVipinfo) {
        super.save(dpVipinfo);
    }

    /**
     * 更新状态
     *
     * @param dpVipinfo
     */
    @Override
    @Transactional
    public void updateStatus(DpVipinfo dpVipinfo) {
        super.updateStatus(dpVipinfo);
    }

    /**
     * 删除数据
     *
     * @param dpVipinfo
     */
    @Override
    @Transactional
    public void delete(DpVipinfo dpVipinfo) {
        super.delete(dpVipinfo);
    }

    public enum VipTimeUnitEnum {
        DAY("1", "天"),
        WEEK("2", "周"),
        MONTH("3", "月"),
        YEAR("4", "年");

        private String unit;
        private String name;

        VipTimeUnitEnum(String unit, String name) {
            this.unit = unit;
            this.name = name;
        }

        public String getUnit() {
            return unit;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public void setUnit(String unit) {
            this.unit = unit;
        }

        public static String getNameByUnit(String unit) {
            VipTimeUnitEnum[] values = VipTimeUnitEnum.values();
            for (VipTimeUnitEnum value : values) {
                if (value.getUnit().equals(unit)) {
                    return value.getName();
                }
            }
            return null;
        }
    }
}